import java.io.File;
import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25397
 * Date: 2021-11-25
 * Time: 16:34
 */

public class Test {
    /*public static void main(String[] args) {
        int []array={1,2,3};
        try{
            array=null;
            System.out.println(array[2]);
            System.out.println("haha");
        }catch (ArrayIndexOutOfBoundsException e){
            e.printStackTrace();//通过e打印栈上的信息
            System.out.println("已捕捉一个数组越界异常");
        }catch (NullPointerException e){
            System.out.println("已捕捉一个空指针异常");
        }
        System.out.println("hello");
    }*/

    /*public static void main(String[] args) {
        int []arr={1,2,3};
        try {
            System.out.println("before");
            arr = null;
            System.out.println(arr[100]);
            System.out.println("after");
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("after try catch");
    }*/

    /*public static String readFile() {
        // 尝试打开文件, 并读其中的一行.
        File file = new File("d:/test.txt");
        // 使用文件对象构造 Scanner 对象.
        Scanner sc = new Scanner(file);
        return sc.nextLine();
    }
    public static void main(String[] args) {
        System.out.println(readFile());
    }*/

    /*public static void func(){
        func();
    }

    public static void main(String[] args) {
        func();
    }*/

    /*public static void main(String[] args) {
        int[] arr = {1, 2, 3};
        try {
            arr = null;
            System.out.println(arr[2]);
            System.out.println("haha");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("捕捉到一个异常");
        }catch (ArrayIndexOutOfBoundsException f){
            f.printStackTrace();
            System.out.println("捕捉到一个异常");
        }
        System.out.println("hello");
    }*/


    /*public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        try{
            int n=scanner.nextInt();
            System.out.println(10/n);
        }catch (ArithmeticException e){
            e.printStackTrace();
            System.out.println("算术异常，可能0作为了除数");
        }finally {
            //finally一般用作资源的关闭
            System.out.println("finally已执行");
            scanner.close();//Scanner也是一种资源，类似文件，打开后，不需要了，最好关闭
        }
        System.out.println("after");
    }*/

    /*public static void main(String[] args) {
        try(Scanner scanner=new Scanner(System.in)){
            int n=scanner.nextInt();
            System.out.println(10/n);
        }catch (ArithmeticException e){
            e.printStackTrace();
            System.out.println("算术异常，可能0作为了除数");
        }finally {
            //finally一般用作资源的关闭
            System.out.println("finally已执行");
        }
        System.out.println("after");
    }*/


}
